﻿<UserControl 
    x:Class="FU.Capstones.IMS.Web.Silverlight.Views.ProductDetail"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
    xmlns:Controls="clr-namespace:FU.Capstones.IMS.Web.Silverlight.Controls"
    xmlns:NControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
	xmlns:DControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Data"
    xmlns:Navigation="clr-namespace:Navigation.Silverlight;assembly=Navigation.Silverlight"
	xmlns:Common="clr-namespace:FU.Capstones.IMS.Web.Common;assembly=FU.Capstones.IMS.Web.Common"
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
    xmlns:Controls1="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"
    Navigation:ViewModel.TypeName="FU.Capstones.IMS.Web.Silverlight.ViewModels.ProductDetailViewModel"
    >
	
    <UserControl.Resources>
        <Common:DataContextProxy x:Key="DataContextProxy"/>
    </UserControl.Resources>

    <telerik:RadBusyIndicator
        BusyContent="Đang kết nối tới máy chủ..."
        IsBusy="{Binding Path=ServiceCallCounter, Converter={StaticResource IntegerToBoolConverter}}"
        >
        <Grid x:Name="LayoutRoot" Style="{StaticResource ViewGridStyle}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="10"/>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <!--Title-->
            <Grid Grid.ColumnSpan="4">

                <Grid.Background>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop0}"/>
                        <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop1}"/>
                        <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop2}"/>
                        <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop3}"/>
                    </LinearGradientBrush>
                </Grid.Background>

                <TextBlock 
                        x:Name="lblTitle" 
                        Style="{StaticResource TextBlockTitlePageStyle}"                   
                        Text="Thông tin sản phẩm" />
            </Grid>
			
			<NControls:RadTabControl                
                Grid.Row="2"  Grid.Column="0" Grid.ColumnSpan="4"
                Background="Transparent"
                >
				<NControls:RadTabItem
                    Header="Thông tin sản phẩm"
                    Background="Transparent"
                    >
			
		            <!--Data field-->
		            <Grid x:Name="DataField" Grid.Column="1" Grid.Row="2">
		                <Grid.RowDefinitions>
		                    <RowDefinition Height="Auto"/>
		                    <RowDefinition Height="Auto"/>
		                    <RowDefinition Height="Auto"/>
		                    <RowDefinition Height="Auto"/>
		                    <RowDefinition Height="Auto"/>
		                    <RowDefinition Height="Auto"/>
							<RowDefinition Height="Auto"/>
		                    <RowDefinition />
		                </Grid.RowDefinitions>
		                <Grid.ColumnDefinitions>
		                    <ColumnDefinition Width="*"/>
							<ColumnDefinition Width="Auto"/>
		                    <ColumnDefinition Width="Auto"/>
		                    <ColumnDefinition Width="Auto"/>
		                    <ColumnDefinition Width="Auto"/>
							<ColumnDefinition Width="*"/>
		                </Grid.ColumnDefinitions>

		                <!--Mã sản phẩm-->
		                <TextBlock 
		                Grid.Row="0" Grid.Column="1"
		                    x:Name="lblcProductCode"
		                    Style="{StaticResource TextBlockNormalStyle}"
		                    >
		                    <Run Text="{StaticResource ProductCodeLabelText}" />
		                    <Run Text=" *" Foreground="Red" />
		                </TextBlock>
		                <TextBox 
		                    Grid.Row="0" Grid.Column="2"
		                    x:Name="txtcProductCode"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
		                    Style="{StaticResource TextBoxNormalStyle}"
		                    Text="{Binding Path=Product.ProductCode, Mode=TwoWay, ValidatesOnDataErrors=True}"
		                />

		                <!--Tên sản phẩm-->
		                <TextBlock 
		                    Grid.Row="1" Grid.Column="1"
		                    x:Name="lblcProductName"
		                    Style="{StaticResource TextBlockNormalStyle}"
		                    >
		                    <Run Text="{StaticResource ProductNameLabelText}" />
		                    <Run Text=" *" Foreground="Red" />
		                </TextBlock>
		                <TextBox 
		                    Grid.Row="1" Grid.Column="2"
		                    x:Name="txtcProductName"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
		                    Style="{StaticResource TextBoxNormalStyle}"
		                    Text="{Binding Path=Product.ProductName, Mode=TwoWay, ValidatesOnDataErrors=True}"
		                />

		                <!--Miêu tả sản phẩm-->
		                <TextBlock 
		                    Grid.Row="0" Grid.Column="3"
		                    x:Name="lblcDescription"
		                    Style="{StaticResource TextBlockNormalStyle}"
		                    Text="{StaticResource BriefDescriptionLabelText}"
		                />
		                <TextBox 
		                    Grid.Row="0" Grid.Column="4" Grid.RowSpan="2" 
		                    x:Name="txtcDescription"                
		                    Style="{StaticResource TextBoxMultilineStyle}"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
		                    Text="{Binding Path=Product.Description, Mode=TwoWay}" />
					</Grid>

				</NControls:RadTabItem>
				
				<NControls:RadTabItem
                    Header="Thành phần cấu thành"
                    Background="Transparent"
                    >
					<Grid Background="Transparent">
						<Grid.ColumnDefinitions>
		                    <ColumnDefinition Width="10"/>
							<ColumnDefinition Width="*"/>
		                    <ColumnDefinition Width="10"/>
							
		                </Grid.ColumnDefinitions>
		                <Grid.RowDefinitions>
		                    <RowDefinition Height="Auto" />
		                    <RowDefinition Height="Auto" />
		                    <RowDefinition Height="Auto" />
		                    <RowDefinition Height="Auto" />
		                    <RowDefinition Height="Auto" />
							
		                    
		                </Grid.RowDefinitions>

		                
		                <!--Grid view-->
		                <telerikGrid:RadGridView 
		                    x:Name="grvProductQuantity"
		                    Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4"
		                    Style="{StaticResource RadGridViewNormal}"
		                    ItemsSource="{Binding Path=MaterialCollection, Mode=TwoWay}"
		                    >
		                    <telerikGrid:RadGridView.Columns>
                                <telerikGrid:GridViewColumn
                                    Header="Chọn"
                                    IsSortable="True"
                                    SortMemberPath="IsSelected"
                                    >
                                    
                                    <telerikGrid:GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <CheckBox
                                                HorizontalAlignment="Center"
                                                IsChecked="{Binding Path=IsSelected, Mode=TwoWay}"
                                                IsEnabled ="{Binding Path=DataSource.CanEditOrAdd, Mode=OneWay, Source={StaticResource DataContextProxy}}" 
                                                Command="{Binding Path=DataSource.SelectCommand, Source={StaticResource DataContextProxy}}"
                                                CommandParameter="{Binding Path=MaterialID}"
                                            />
                                        </DataTemplate>
                                    </telerikGrid:GridViewColumn.CellTemplate>
                                </telerikGrid:GridViewColumn>
                                <!--MaterialCode-->
		                        <telerikGrid:GridViewDataColumn 
		                            DataMemberBinding="{Binding Path=MaterialCode}"
		                            Header="{StaticResource MaterialCodeLabelText}"
		                            Width="110" HeaderTextAlignment="Center"
		                            />

		                        <!--MaterialName-->
		                        <telerikGrid:GridViewDataColumn 
		                            DataMemberBinding="{Binding Path=MaterialName}"
		                            Header="{StaticResource MaterialNameLabelText}"
		                            Width="200" HeaderTextAlignment="Center"
		                            />

                                <telerikGrid:GridViewColumn 
		                            Header="Số lượng"
		                            Width="100" HeaderTextAlignment="Center">
                                    <telerikGrid:GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <Controls1:RadNumericUpDown 
                                                IsInteger="True"
                                                IsEnabled="{Binding Path=IsSelected, Mode=OneWay}"
                                                Value="{Binding Path=Quantity, Mode=TwoWay}"
                                                Minimum="1"                                                
                                            />
                                        </DataTemplate>
                                    </telerikGrid:GridViewColumn.CellTemplate>
                                </telerikGrid:GridViewColumn>

                            </telerikGrid:RadGridView.Columns>
		                </telerikGrid:RadGridView>
						
						<Grid Grid.Row="2" Grid.Column="1" >	
						
				            <DControls:RadDataPager
				            	x:Name="DataPager"
				                Source="{Binding Path=MaterialCollection, Mode=TwoWay}"
				                Style="{StaticResource DataPagerNormalStyle}"
								HorizontalAlignment="Right"
			                />
                            
						 </Grid>

		            </Grid>
			
				</NControls:RadTabItem>
			</NControls:RadTabControl>

            <TextBlock
                Grid.Row="4" Grid.Column="1"
                Style="{StaticResource ErrorMessageTextBlockStyle}"
                Text="{Binding Path=Message, Mode=TwoWay}"
                Visibility="{Binding Path=ErrorMessageVisibility, Mode=TwoWay}"
            />

            <TextBlock
                Grid.Row="4" Grid.Column="1"
                Style="{StaticResource SuccessfulMessageTextBlockStyle}"
                Text="{Binding Path=Message, Mode=TwoWay}"
                Visibility="{Binding Path=MessageVisibility, Mode=TwoWay}"
            />

            <!--Button-->
            <StackPanel
                Orientation="Horizontal" HorizontalAlignment="Center"
                Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="3">
                <!--Buttons-->
                <Controls:SaveButtonControl 
                    Visibility ="{Binding Path=CanEditOrAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                    />

                <Controls:ResetButtonControl 
                    Visibility ="{Binding Path=CanEditOrAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                    />

                <Controls:BackButtonControl
                    />
            </StackPanel>
        </Grid>
    </telerik:RadBusyIndicator>
</UserControl>
